package com.qiantu.api.http;

import android.os.Build;
import android.text.TextUtils;

import androidx.lifecycle.LifecycleOwner;

import com.google.gson.Gson;
import com.hjq.http.EasyHttp;
import com.hjq.http.EasyLog;
import com.hjq.http.config.IRequestInterceptor;
import com.hjq.http.listener.HttpCallback;
import com.hjq.http.model.HttpHeaders;
import com.hjq.http.model.HttpParams;
import com.hjq.http.request.HttpRequest;
import com.qiantu.api.BuildConfig;
import com.qiantu.api.entity.ApplyTransferBean;
import com.qiantu.api.entity.BeforeAfterTimesBean;
import com.qiantu.api.entity.BeforePagataBean;
import com.qiantu.api.entity.ControllerBean;
import com.qiantu.api.entity.ControllerSettingDto;
import com.qiantu.api.entity.CreateSceneResult;
import com.qiantu.api.entity.DeviceBean;
import com.qiantu.api.entity.DeviceCustomKeyBean;
import com.qiantu.api.entity.DeviceCustomNewBean;
import com.qiantu.api.entity.DeviceCustomUrlBean;
import com.qiantu.api.entity.DeviceLedSetBean;
import com.qiantu.api.entity.DeviceOtherBean;
import com.qiantu.api.entity.ElecBayBean;
import com.qiantu.api.entity.ElecPeriodBean;
import com.qiantu.api.entity.ElecPriceBean;
import com.qiantu.api.entity.FirmwareUpgradeBean;
import com.qiantu.api.entity.FirmwareUpgradeInfoBean;
import com.qiantu.api.entity.FloorBean;
import com.qiantu.api.entity.GloBaLoPeRationDeviceBean;
import com.qiantu.api.entity.HikallBean;
import com.qiantu.api.entity.HouseBean;
import com.qiantu.api.entity.IntTaskID;
import com.qiantu.api.entity.KGSwitchBindBean;
import com.qiantu.api.entity.KGXAddData;
import com.qiantu.api.entity.KGXcollectionData;
import com.qiantu.api.entity.LinkageBean;
import com.qiantu.api.entity.LinkageListBean;
import com.qiantu.api.entity.LinkageNewBean;
import com.qiantu.api.entity.LoginBean;
import com.qiantu.api.entity.MemberBean;
import com.qiantu.api.entity.MessageBean;
import com.qiantu.api.entity.MusicListBean;
import com.qiantu.api.entity.MusiclikeListBean;
import com.qiantu.api.entity.PanelBindConfig;
import com.qiantu.api.entity.PanelBindConfigs;
import com.qiantu.api.entity.PanelBindStatusBean;
import com.qiantu.api.entity.PlayInfoBean;
import com.qiantu.api.entity.ProductBaseInfoBean;
import com.qiantu.api.entity.ProtocolSwitchResultBean;
import com.qiantu.api.entity.QueryCodeResultBean;
import com.qiantu.api.entity.QueryCodeResultListBean;
import com.qiantu.api.entity.RoomBean;
import com.qiantu.api.entity.RoomGalleryBean;
import com.qiantu.api.entity.RoomShareBean;
import com.qiantu.api.entity.ScanWirelessControllerBean;
import com.qiantu.api.entity.SceneBean;
import com.qiantu.api.entity.SceneDetailBean;
import com.qiantu.api.entity.SceneInterruptModeBean;
import com.qiantu.api.entity.SceneManagerBean;
import com.qiantu.api.entity.SchemeConfig;
import com.qiantu.api.entity.SettingBean;
import com.qiantu.api.entity.SmsBean;
import com.qiantu.api.entity.SourceHomepageBean;
import com.qiantu.api.entity.SwitchBindBean;
import com.qiantu.api.entity.UniversalDeviceAction;
import com.qiantu.api.entity.UniversalDeviceData;
import com.qiantu.api.entity.UserInfoBean;
import com.qiantu.api.entity.UserPushSetsBean;
import com.qiantu.api.entity.VersionBean;
import com.qiantu.api.entity.WeatherInfoBean;
import com.qiantu.api.http.exception.ResultException;
import com.qiantu.api.http.model.HttpData;
import com.qiantu.api.utils.Md5Util;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Response;

/**
 * @ClassName HttpManager
 * @Description TODO
 * @Author ShiJunqiang
 * @Date 2021/11/18 20:31
 * @Version 1.0
 */
public class LLHttpManager {

    public static void sendSms(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<SmsBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("sms/send", data))
                .request(listener);
    }

    public static void aftersalesSendSms(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<SmsBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("aftersales/feedback/sendcode", data))
                .request(listener);
    }

    public static void createAccountQuestion(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("aftersales/feedback/createaccountquestion", data))
                .request(listener);
    }

    /**
     * 修改房屋信息
     *
     * @param lifecycleOwner
     * @param houseInfoBean
     * @param listener
     */
    public static void house_editinfo(LifecycleOwner lifecycleOwner, HouseBean houseInfoBean, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/editinfo", houseInfoBean))
                .request(listener);
    }

    public static void getHouseBySerialNo(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<HouseBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/homepage", data))
                .request(listener);
    }

    public static void editDefaultHouse(LifecycleOwner lifecycleOwner, String loginToken, String houseSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner).interceptor(new IRequestInterceptor() {
            @Override
            public void interceptArguments(HttpRequest<?> httpRequest, HttpParams params, HttpHeaders headers) {
                if (!TextUtils.isEmpty(loginToken)) {
                    headers.put("Authorization", "Bearer " + loginToken);
                }
                String phoneInfo = "(Android " + Build.VERSION.RELEASE + ";" + Build.BRAND + " " + Build.MODEL + ")";
                headers.put("User-Agent:", "Linlu/" + BuildConfig.VERSION_NAME + " " + phoneInfo);
            }

            @Override
            public Response interceptResponse(HttpRequest<?> httpRequest, Response response) throws Exception {
                if (response.code() == 401 || response.code() == 403) {
                    String text = response.body().string();
                    // 打印这个 Json 或者文本
                    EasyLog.printJson(httpRequest, text);
                    Gson gson = new Gson();
                    HttpData httpData = gson.fromJson(text, HttpData.class);
                    // 代表执行失
                    throw new ResultException(httpData.getMessage(), httpData);
                }
                return response;
            }
        }).api(new DataApi("user/user/editdefaulthouse", data))
                .request(listener);
    }

    public static void setPwd(LifecycleOwner lifecycleOwner, String pwd, String comfirmPwd, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        pwd = Md5Util.getMD5ofStr(pwd);
        comfirmPwd = Md5Util.getMD5ofStr(comfirmPwd);
        data.put("pwd", pwd);
        data.put("comfirmPwd", comfirmPwd);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/setpwd", data))
                .request(listener);
    }

    public static void updatePwd(LifecycleOwner lifecycleOwner, String oldPwd, String newPwd, String confirmNewPwd, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        oldPwd = Md5Util.getMD5ofStr(oldPwd);
        newPwd = Md5Util.getMD5ofStr(newPwd);
        confirmNewPwd = Md5Util.getMD5ofStr(confirmNewPwd);
        data.put("oldPwd", oldPwd);
        data.put("newPwd", newPwd);
        data.put("confirmNewPwd", confirmNewPwd);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/updatepwd", data))
                .request(listener);
    }

    public static void checkPwd(LifecycleOwner lifecycleOwner, String pwd, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pwd", Md5Util.getMD5ofStr(pwd));
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/checkpwd", data))
                .request(listener);
    }

    public static void getbasichouseinfolist(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<List<HouseBean>>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/getbasichouseinfolist"))
                .request(listener);
    }

    public static void house_getrooms(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<RoomBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/getrooms", data))
                .request(listener);
    }

    public static void house_getfloors(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<FloorBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/getfloors", data))
                .request(listener);
    }

    public static void house_getdevices(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<DeviceBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/allDevices", data))
                .request(listener);
    }

//    public static void house_getscenes(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<SceneBean>>> listener) {
//        Map<String, Object> data = new HashMap<>();
//        data.put("houseSerialNo", houseSerialNo);
//        EasyHttp.post(lifecycleOwner)
//                .api(new DataApi("device/house/allscenes", data))
//                .request(listener);
//    }

    public static void house_getscenes(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<SceneBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/allscenes", data))
                .request(listener);
//        device/scene/gethousescenes
    }

    public static void deleteHouse(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/delete", data))
                .request(listener);
    }

    public static void quitHouse(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/quithouse", data))
                .request(listener);
    }

    public static void applogin(LifecycleOwner lifecycleOwner, String phone, String smsCode, String smsId, String phoneSerialNo, String token, HttpCallback<HttpData<LoginBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("phone", phone);
        data.put("code", smsCode);
        data.put("smsType", "login_boyun");
        data.put("smsId", smsId);
        Map<String, Object> loginDevice = new HashMap<>();
        loginDevice.put("platform", 2);
        loginDevice.put("phoneName", Build.MANUFACTURER + "_" + Build.MODEL);
        loginDevice.put("phoneSerialNo", phoneSerialNo);
        loginDevice.put("token", token);
        loginDevice.put("version", Build.VERSION.RELEASE);
//        loginDevice.put("longitude", "");
//        loginDevice.put("latitude", "");
        data.put("loginDevice", loginDevice);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/applogin", data))
                .request(listener);
    }

    public static void changeServerAccount(LifecycleOwner lifecycleOwner, String phone, String phoneSerialNo, String token, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("platform", 2);
        data.put("phoneName", phone);
        data.put("phoneSerialNo", phoneSerialNo);
        data.put("token", token);
        data.put("version", Build.VERSION.RELEASE);
//        loginDevice.put("longitude", "");
//        loginDevice.put("latitude", "");
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/active", data))
                .request(listener);
    }

    public static void changeServerAccount(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/active", data))
                .request(listener);
    }

    public static void loginWithPwd(LifecycleOwner lifecycleOwner, String phone, String pwd, String phoneSerialNo, String token, HttpCallback<HttpData<LoginBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("phone", phone);
        data.put("pwd", pwd);
        Map<String, Object> loginDevice = new HashMap<>();
        loginDevice.put("platform", 2);
        loginDevice.put("phoneName", Build.MANUFACTURER + "_" + Build.MODEL);
        loginDevice.put("phoneSerialNo", phoneSerialNo);
        loginDevice.put("token", token);
        loginDevice.put("version", Build.VERSION.RELEASE);
//        loginDevice.put("longitude", "");
//        loginDevice.put("latitude", "");
        data.put("loginDevice", loginDevice);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/loginwithpwd", data))
                .request(listener);
    }

    public static void logout(LifecycleOwner lifecycleOwner, String phoneSerialNo, String token, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> loginDevice = new HashMap<>();
        loginDevice.put("platform", 2);
        loginDevice.put("phoneName", Build.MANUFACTURER + "_" + Build.MODEL);
        loginDevice.put("phoneSerialNo", phoneSerialNo);
        loginDevice.put("token", token);
        loginDevice.put("version", Build.VERSION.RELEASE);
//        loginDevice.put("longitude", "");
//        loginDevice.put("latitude", "");
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/logout", loginDevice))
                .request(listener);
    }

    public static void closeAccount(LifecycleOwner lifecycleOwner, String phone, String code, String smsId, HttpCallback<HttpData<LoginBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("phone", phone);
        data.put("code", code);
        data.put("smsType", "closeAccount_boyun");
        data.put("smsId", smsId);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/closeaccount", data))
                .request(listener);
    }

    public static void addHouse(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<HouseBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/create", data))
                .request(listener);
    }

    public static void addHouseWithFloor(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<HouseBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/create4floors", data))
                .request(listener);
    }
    public static void addFloor(LifecycleOwner lifecycleOwner, String houseSerialNo, String floorName, HttpCallback<HttpData<FloorBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("floorName", floorName);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/create", data))
                .request(listener);
    }

    public static void addRoom(LifecycleOwner lifecycleOwner, String floorId, String name, String roomType, HttpCallback<HttpData<RoomBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("floorSerialNo", floorId);
        data.put("name", name);
        data.put("typeId",roomType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/create", data))
                .request(listener);
    }

    public static void editRoom(LifecycleOwner lifecycleOwner, String roomSerialNo, String floorSerialNo, String name, String typeId, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("roomSerialNo", roomSerialNo);
        data.put("floorSerialNo", floorSerialNo);
        data.put("name", name);
        data.put("typeId", typeId);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/edit", data))
                .request(listener);
    }


    public static void editFloorName(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/editname", data))
                .request(listener);
    }

    public static void editBasicInfo(LifecycleOwner lifecycleOwner, UserInfoBean data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/editbasicinfo", data))
                .request(listener);
    }

    public static void sceneBelong(LifecycleOwner lifecycleOwner, int type, String targetSerialNo, List<String> sceneSerialNoList, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNoList", sceneSerialNoList);
        data.put("targetSerialNo", targetSerialNo);
        data.put("type", type);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/belong", data))
                .request(listener);
    }

    public static void sceneBelong(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/belong", data))
                .request(listener);
    }

    public static void deviceBelong(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/belong", data))
                .request(listener);
    }

    public static void sceneIsFavourite(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/isfavourite", data))
                .request(listener);
    }

    public static void sceneIsDisable(LifecycleOwner lifecycleOwner, String sceneSerialNo, boolean isDisable, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> sceneSerialNoList = new ArrayList<>();
        sceneSerialNoList.add(sceneSerialNo);
        data.put("sceneSerialNoList", sceneSerialNoList);
        data.put("isDisable", isDisable);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/isdisable", data))
                .request(listener);
    }

    public static void privateSceneManager(LifecycleOwner lifecycleOwner, String sceneSerialNo, int sceneType, HttpCallback<HttpData<List<SceneManagerBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNo", sceneSerialNo);
        data.put("sceneType", sceneType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/subscnenmanage", data))
                .request(listener);
    }

    public static void deviceIsFavourite(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/isfavourite", data))
                .request(listener);
    }

    public static void sceneSort(LifecycleOwner lifecycleOwner, List<SceneBean> sceneBeans, HttpCallback<HttpData<Void>> listener) {
        if (sceneBeans == null) return;
        Map<String, Object> data = new HashMap<>();
        List<Map<String, String>> sortSceneList = new ArrayList<>();
        for (int i = 0; i < sceneBeans.size(); i++) {
            SceneBean bean = sceneBeans.get(i);
            bean.setSort(i);
            bean.setId(null);
            Map<String, String> map = new HashMap<>();
            map.put("sceneSerialNo", bean.getSceneSerialNo());
            map.put("sort", String.valueOf(i));
            sortSceneList.add(map);
        }
        data.put("sortSceneList", sortSceneList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/sort", data))
                .request(listener);
    }

    public static void roomSort(LifecycleOwner lifecycleOwner, List<RoomBean> roomBeans, HttpCallback<HttpData<Void>> listener) {
        if (roomBeans == null) return;
        Map<String, Object> data = new HashMap<>();
        List<Map<String, String>> sortRoomList = new ArrayList<>();
        for (int i = 0; i < roomBeans.size(); i++) {
            RoomBean bean = roomBeans.get(i);
            bean.setSort(i);
            Map<String, String> map = new HashMap<>();
            map.put("roomSerialNo", bean.getRoomSerialNo());
            map.put("sort", String.valueOf(i));
            sortRoomList.add(map);
        }
        data.put("sorts", sortRoomList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/sort", data))
                .request(listener);
    }

    public static void deleteRoom(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/delete", data))
                .request(listener);
    }

    public static void deleteFloor(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/delete", data))
                .request(listener);
    }

    public static void deleteScene(LifecycleOwner lifecycleOwner, List<String> sceneSerialNoList, HttpCallback<HttpData<Boolean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNoList", sceneSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/deleteall", data))
                .request(listener);
    }

    public static void sceneOperation(LifecycleOwner lifecycleOwner, String sceneSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNo", sceneSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/operation", data))
                .request(listener);
    }

    public static void getSceneByDeviceSerialNo(LifecycleOwner lifecycleOwner, String deviceSerialNo, String houseSerialNo, HttpCallback<HttpData<List<SceneBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceItemSerialNo", deviceSerialNo);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/gescenesbydeviceitem", data))
                .request(listener);
    }

    public static void getSceneByDeviceGroupSerialNo(LifecycleOwner lifecycleOwner, String deviceSerialNo, String houseSerialNo, HttpCallback<HttpData<List<SceneBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceSerialNo);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/gescenesbydevicegroup", data))
                .request(listener);
    }

    public static void sceneCreate(LifecycleOwner lifecycleOwner, SceneDetailBean editScene, HttpCallback<HttpData<CreateSceneResult>> listener) {
        //String data = new Gson().toJson(editScene);
        if (editScene.getSceneTasks() != null) {
            for (int i = 0; i < editScene.getSceneTasks().size(); i++) {
                SceneDetailBean.SceneTaskBean sceneTask = editScene.getSceneTasks().get(i);
                //清空,后台会自动生成
                sceneTask.setTaskBriefing(null);
                sceneTask.setSort(i + 1);
            }
        }
        //后台参数修改不一致
//        editScene.setSceneTask(editScene.getSceneTasks());
//        editScene.setSceneTasks(null);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/create", editScene))
                .request(listener);
    }

    public static void sceneSave(LifecycleOwner lifecycleOwner, SceneDetailBean editScene, HttpCallback<HttpData<CreateSceneResult>> listener) {
        //String data = new Gson().toJson(editScene);
        if (editScene.getSceneTasks() != null) {
            for (int i = 0; i < editScene.getSceneTasks().size(); i++) {
                SceneDetailBean.SceneTaskBean sceneTask = editScene.getSceneTasks().get(i);
                //清空,后台会自动生成
                sceneTask.setTaskBriefing(null);
                sceneTask.setSort(i + 1);
            }
        }
//        //后台参数修改不一致
//        editScene.setSceneTask(editScene.getSceneTasks());
//        editScene.setSceneTasks(null);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/save", editScene))
                .request(listener);
    }

    /**
     * 获取场景详细信息
     *
     * @param lifecycleOwner
     * @param sceneSerialNo
     * @param listener
     */
    public static void getSceneDetailInfo(LifecycleOwner lifecycleOwner, String sceneSerialNo, HttpCallback<HttpData<List<SceneDetailBean>>> listener) {
        List<String> sceneSerialNoList = new ArrayList<>();
        sceneSerialNoList.add(sceneSerialNo);
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNoList", sceneSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/getall", data))
                .request(listener);
    }

    //根据指令操作设备
    public static void operationDevice(LifecycleOwner lifecycleOwner, String deviceSerialNo, Map<String, Object> stateData, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        Map<String, Object> deviceItem = new HashMap<>();
        deviceItem.put("deviceSerialNo", deviceSerialNo);
        deviceItem.put("stateData", stateData);
        List<Map<String, Object>> list = new ArrayList();
        list.add(deviceItem);
        data.put("deviceList", list);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/operationdevice", data))
                .request(listener);
    }

    public static void deviceAllClose(LifecycleOwner lifecycleOwner, List<Map<String, Object>> operations, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceList", operations);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/operationdevice", data))
                .request(listener);
    }

    /**
     * 获取消息中心列表
     *
     * @param lifecycleOwner
     * @param pageIndex
     * @param pageSize
     * @param category
     * @param listener
     */
    public static void getMessages(LifecycleOwner lifecycleOwner, int pageIndex, int pageSize, int category, String houseSerialNo, HttpCallback<HttpData<MessageBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pageIndex", pageIndex);
        data.put("pageSize", pageSize);
        data.put("houseSerialNo",houseSerialNo);
        data.put("category", category);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/information/getmessages", data))
                .request(listener);
    }

    public static void getControllers(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<ControllerBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/controllerbases", data))
                .request(listener);
    }

    public static void getAllSetting(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<SettingBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/getallsetting"))
                .request(listener);
    }

    public static void getMessageSetting(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<SettingBean.SettingDTO.MessageDTO>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/getmessagesetting"))
                .request(listener);
    }

    public static void getInterfaceCustomizationSetting(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<SettingBean.SettingDTO.InterfaceCustomizationDTO>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/getinterfacecustomizationsetting"))
                .request(listener);
    }

    public static void getIntelligentControlModeSetting(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<SettingBean.SettingDTO.IntelligentControlModeDTO>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/getintelligentcontrolmodesetting"))
                .request(listener);
    }

    public static void getTouchFeedbackSetting(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<SettingBean.SettingDTO.TouchFeedbackDTO>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/gettouchfeedbacksetting"))
                .request(listener);
    }

    public static void setInterfaceCustomizationSetting(LifecycleOwner lifecycleOwner, SettingBean.SettingDTO.InterfaceCustomizationDTO data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/setinterfacecustomizationsetting", data))
                .request(listener);
    }

    public static void setDownloadWifi(LifecycleOwner lifecycleOwner, boolean data, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> params = new HashMap<>();
        params.put("downloadInWifi", data);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/setdownloadinwifi", params))
                .request(listener);
    }

    public static void setAgingAdaptation(LifecycleOwner lifecycleOwner, boolean data, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> params = new HashMap<>();
        params.put("agingAdaptation", data);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/setagingadaptation", params))
                .request(listener);
    }

    public static void setMessageSetting(LifecycleOwner lifecycleOwner, Map<String, Object> params, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/setmessagesetting", params))
                .request(listener);
    }

    public static void setIntelligentControlModeSetting(LifecycleOwner lifecycleOwner, SettingBean.SettingDTO.IntelligentControlModeDTO data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/setintelligentcontrolmodesetting", data))
                .request(listener);
    }

    public static void setTouchFeedbackSetting(LifecycleOwner lifecycleOwner, SettingBean.SettingDTO.TouchFeedbackDTO data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/settouchfeedbacksetting", data))
                .request(listener);
    }

    public static void codeVerify(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("sms/verify", data))
                .request(listener);
    }

    public static void changePhone(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/changephone", data))
                .request(listener);
    }

    public static void updateControllerName(LifecycleOwner lifecycleOwner, String controllerSerialNo, String name, HttpCallback<HttpData<Void>> listener) {
        Map<String, String> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("name", name);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/save", data))
                .request(listener);
    }

    public static void deviceUpgradeInfo(LifecycleOwner lifecycleOwner, int upgradeType, String upgradeSerialNo, HttpCallback<HttpData<FirmwareUpgradeInfoBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        //设备:1, 控制器:2
        data.put("upgradeType", upgradeType);
        data.put("upgradeSerialNo", upgradeSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceupgrade/upgradeinfo", data))
                .request(listener);
    }

    public static void deviceUpgradeQuery(LifecycleOwner lifecycleOwner, String queryCode, HttpCallback<HttpData<QueryCodeResultBean<FirmwareUpgradeBean, Object>>> listener) {
        Map<String, String> data = new HashMap<>();
        data.put("queryCode", queryCode);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceupgrade/upgradequery", data))
                .request(listener);
    }

    public static void deviceUpgrade(LifecycleOwner lifecycleOwner, int upgradeType, String upgradeSerialNo, HttpCallback<HttpData<QueryCodeResultBean<FirmwareUpgradeBean, Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        //设备:1, 控制器:2
        data.put("upgradeType", upgradeType);
        data.put("upgradeSerialNo", upgradeSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceupgrade/upgrade", data))
                .request(listener);
    }

    public static void controllerIsDisable(LifecycleOwner lifecycleOwner, String controllerSerialNo, boolean isDisable, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> controllerSerialNos = new ArrayList<>();
        controllerSerialNos.add(controllerSerialNo);
        data.put("controllerSerialNo", controllerSerialNos);
        data.put("isDisable", isDisable);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/isdisable", data))
                .request(listener);
    }

    public static void controllerDelete(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> controllerSerialNos = new ArrayList<>();
        controllerSerialNos.add(controllerSerialNo);
        data.put("controllerSerialNo", controllerSerialNos);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/delete", data))
                .request(listener);
    }

    public static void deviceIsDisable(LifecycleOwner lifecycleOwner, List<String> deviceSerialNoList, boolean isDisable, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNoList", deviceSerialNoList);
        data.put("isDisable", isDisable);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/isdisable", data))
                .request(listener);
    }

    public static void deviceDelete(LifecycleOwner lifecycleOwner, List<String> deviceSerialNoList, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNoList", deviceSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/delete", data))
                .request(listener);
    }

    public static void deviceIsHomePage(LifecycleOwner lifecycleOwner, List<String> deviceSerialNoList, boolean isHomePage, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNoList", deviceSerialNoList);
        data.put("isHomePage", isHomePage);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/ishomepage", data))
                .request(listener);
    }

    public static void modifyDevice(LifecycleOwner lifecycleOwner, DeviceBean device, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo", device.getDeviceSerialNo());
        data.put("sort", device.getSort());
        data.put("name", device.getName());
        data.put("isFavourite", device.getIsFavourite());
        data.put("isDisable", device.getIsDisable());
        data.put("imageUrl", device.getImageUrl());
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/save", data))
                .request(listener);
    }

    public static void changeDeviceType(LifecycleOwner lifecycleOwner, String deviceSerialNo, String deviceType, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo", deviceSerialNo);
        data.put("deviceType", deviceType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/changedevicetype", data))
                .request(listener);
    }

    /**
     * 获取时刻列表
     *
     * @param lifecycleOwner
     * @param beforePage
     * @param beforePageSize
     * @param houseSerialNo
     * @param listener
     */
    public static void getTimes(LifecycleOwner lifecycleOwner, int beforePage, int beforePageSize, int requestType, String houseSerialNo, HttpCallback<HttpData<BeforeAfterTimesBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        Map<String, Integer> beforePageData = new HashMap<>();
        beforePageData.put("pagNum", beforePage);
        beforePageData.put("num", beforePageSize);
        data.put("beforePagata", beforePageData);
        Map<String, Integer> afterPageData = new HashMap<>();
        afterPageData.put("pagNum", 1);
        if(requestType == 1){
            afterPageData.put("num", Integer.MAX_VALUE);//首次加载， 未来时刻全部加载出来
        }else if(requestType == 2){//增量刷新，只获取过去时刻
            afterPageData.put("num", 0);
        }
        data.put("afterPagData", afterPageData);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/timerecord/getall", data))
                .request(listener);
    }

    public static void deleteTimeRecord(LifecycleOwner lifecycleOwner, String timeRecordSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> timeRecordSerialNoList = new ArrayList<>();
        timeRecordSerialNoList.add(timeRecordSerialNo);
        data.put("timeRecordSerialNoList", timeRecordSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/timerecord/delete", data))
                .request(listener);
    }


    public static void addControllerByWired(LifecycleOwner lifecycleOwner, String masterSerialNo,String validateCode, String deviceSn, String houseSerialNo, HttpCallback<HttpData<ControllerBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        if (!TextUtils.isEmpty(masterSerialNo)) {
            data.put("masterSerialNo", masterSerialNo);
        }
        if (!TextUtils.isEmpty(validateCode)) {
            data.put("validateCode", validateCode);
        }else{
            data.put("validateCode", "");
        }
        data.put("deviceSn", deviceSn);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/add", data))
                .request(listener);
    }

    public static void addControllerByWifi(LifecycleOwner lifecycleOwner, String masterSerialNo, String deviceMac, String houseSerialNo, HttpCallback<HttpData<ControllerBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        if (!TextUtils.isEmpty(masterSerialNo)) {
            data.put("masterSerialNo", masterSerialNo);
        }
        data.put("deviceMac", deviceMac);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/wifiadd", data))
                .request(listener);
    }

    /**
     * @param lifecycleOwner
     * @param serialNo
     * @param isSwitch
     * @param listener
     */
    public static void deviceIsSwitch(LifecycleOwner lifecycleOwner, String serialNo, boolean isSwitch, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> deviceSerialNoList = new ArrayList<>();
        deviceSerialNoList.add(serialNo);
        data.put("deviceSerialNoList", deviceSerialNoList);
        data.put("isSwitch", isSwitch);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/isswitch", data))
                .request(listener);
    }

    public static void groupDeviceIsSwitch(LifecycleOwner lifecycleOwner, String serialNo, boolean isSwitch, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> deviceSerialNoList = new ArrayList<>();
        deviceSerialNoList.add(serialNo);
        data.put("deviceGroupSerialNos", deviceSerialNoList);
        data.put("isSwitch", isSwitch);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/isswitch", data))
                .request(listener);
    }

    /**
     * @param lifecycleOwner
     * @param pageIndex
     * @param pageSize
     * @param houseSerialNo
     * @param linkageType
     * @param listener
     */
    public static void getLinkages(LifecycleOwner lifecycleOwner, int pageIndex, int pageSize, String houseSerialNo, int linkageType, HttpCallback<HttpData<List<LinkageBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pageIndex", pageIndex);
        data.put("pageSize", pageSize);
        data.put("houseSerialNo", houseSerialNo);
        data.put("linkageType", linkageType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/getall", data))
                .request(listener);
    }

    public static void getLinkagesNew(LifecycleOwner lifecycleOwner, int pageIndex, int pageSize, String houseSerialNo, HttpCallback<HttpData<List<LinkageListBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pageIndex", pageIndex);
        data.put("pageSize", pageSize);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/getlist", data))
                .request(listener);
    }

    public static void getLinkage(LifecycleOwner lifecycleOwner, String linkageSerialNo, HttpCallback<HttpData<LinkageBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("linkageSerialNo", linkageSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/get", data))
                .request(listener);
    }

    public static void getLinkageNew(LifecycleOwner lifecycleOwner, String linkageSerialNo, HttpCallback<HttpData<LinkageNewBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("linkageSerialNo", linkageSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/get", data))
                .request(listener);
    }

    public static void getLinkageByDeviceSerialNo(LifecycleOwner lifecycleOwner, String deviceSerialNo, String houseSerialNo, HttpCallback<HttpData<List<LinkageListBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pageIndex", 1);
        data.put("pageSize", 1000);
        data.put("deviceSerialNo", deviceSerialNo);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/getlistbydevice", data))
                .request(listener);
    }

    public static void getLinkageByDeviceGroupSerialNo(LifecycleOwner lifecycleOwner, String deviceSerialNo, String houseSerialNo, HttpCallback<HttpData<List<LinkageListBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("pageIndex", 1);
        data.put("pageSize", 1000);
        data.put("deviceGroupSerialNo", deviceSerialNo);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/getlistbydevice", data))
                .request(listener);
    }

    public static void linkageCreate(LifecycleOwner lifecycleOwner, LinkageBean linkage, HttpCallback<HttpData<LinkageBean>> listener) {
//        if(linkage == null){
//            return;
//        }
//        Map<String, Object> data = new HashMap<>();
//        data.put("name", linkage.getName());
//        data.put("decideType", linkage.getDecideType());
//        data.put("houseSerialNo", linkage.getHouseSerialNo());
//        if(linkage.getLinkageConditions() != null){
//            Map<String, Object> addLinkageConditionDto = new HashMap<>();
//            for(LinkageBean.LinkageCondition linkageCondition : linkage.getLinkageConditions()){
//                switch (linkageCondition.getConditionType()){
//                    case 1:
//                        addLinkageConditionDto.put("conditionDatetime", linkageCondition);
//                        break;
//                }
//            }
//            data.put("addLinkageConditionDto", addLinkageConditionDto);
//        }
//        if(linkage.getLinkageTasks() != null){
//            Map<String, Object> addLinkageTaskDto = new HashMap<>();
//            for(LinkageBean.LinkageTask linkageTask : linkage.getLinkageTasks()){
//                switch (linkageTask.getTaskType()){
//                    case 1:
//                        addLinkageTaskDto.put("taskDeviceInstruct", linkageTask);
//                        break;
//                }
//            }
//            data.put("addLinkageTaskDto", addLinkageTaskDto);
//        }
        if (linkage.getLinkageConditions() != null) {
            for (int i = 0; i < linkage.getLinkageConditions().size(); i++) {
                LinkageBean.LinkageCondition linkageCondition = linkage.getLinkageConditions().get(i);
                linkageCondition.setSort(i + 1);
            }
        }
        if (linkage.getLinkageTasks() != null) {
            for (int i = 0; i < linkage.getLinkageTasks().size(); i++) {
                LinkageBean.LinkageTask linkageTask = linkage.getLinkageTasks().get(i);
                linkageTask.setSort(i + 1);
            }
        }
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/add", linkage))
                .request(listener);
    }

    public static void linkageEdit(LifecycleOwner lifecycleOwner, LinkageBean linkage, HttpCallback<HttpData<LinkageBean>> listener) {
        if (linkage.getLinkageConditions() != null) {
            for (int i = 0; i < linkage.getLinkageConditions().size(); i++) {
                LinkageBean.LinkageCondition linkageCondition = linkage.getLinkageConditions().get(i);
                linkageCondition.setSort(i + 1);
            }
        }
        if (linkage.getLinkageTasks() != null) {
            for (int i = 0; i < linkage.getLinkageTasks().size(); i++) {
                LinkageBean.LinkageTask linkageTask = linkage.getLinkageTasks().get(i);
                linkageTask.setSort(i + 1);
            }
        }
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/modify", linkage))
                .request(listener);
    }

    public static void linkageEditNew(LifecycleOwner lifecycleOwner, LinkageNewBean linkage, HttpCallback<HttpData<LinkageNewBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/save", linkage))
                .request(listener);
    }

    public static void deleteLinkage(LifecycleOwner lifecycleOwner, String linkageSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("linkageSerialNo", linkageSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/delete", data))
                .request(listener);
    }

    public static void setLinkageDisable(LifecycleOwner lifecycleOwner, String linkageSerialNo, boolean isDisable, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("linkageSerialNo", linkageSerialNo);
        data.put("isDisable", isDisable);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettings/isdisable", data))
                .request(listener);
    }

    public static void setLinkageDisableNew(LifecycleOwner lifecycleOwner, String linkageSerialNo, boolean isDisable, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("linkageSerialNo", linkageSerialNo);
        data.put("isDisable", isDisable);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("linkage/linkagesettingsv2/isdisable", data))
                .request(listener);
    }

    public static void getHouseMembers(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<MemberBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/gethousemembers", data))
                .request(listener);
    }

    public static void deletemember(LifecycleOwner lifecycleOwner, String houseSerialNo, String userSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("userSerialNo", userSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/deletemember", data))
                .request(listener);
    }

    public static void inviteMember(LifecycleOwner lifecycleOwner, String houseSerialNo, String phone, String remark, String roleType, List<MemberBean.MemberPermission> memberPermissiones, HttpCallback<HttpData<MemberBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("phone", phone);
        data.put("remark", remark);
        data.put("roleType",roleType);
        if(memberPermissiones != null){
            data.put("memberPermissions",memberPermissiones);
        }
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/invitemember", data))
                .request(listener);
    }

    public static void changeRole(LifecycleOwner lifecycleOwner, String houseSerialNo, String userSerialNo, int roleType, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("userSerialNo", userSerialNo);
        data.put("roleType",roleType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/saverole", data))
                .request(listener);
    }

    public static void changeRolePermission(LifecycleOwner lifecycleOwner, String houseSerialNo, String userSerialNo, List<MemberBean.MemberPermission> memberPermissiones, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("userSerialNo", userSerialNo);
        data.put("memberPermissions",memberPermissiones);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/savepermission", data))
                .request(listener);
    }

    public static void eidtMemberNickname(LifecycleOwner lifecycleOwner, String userSerialNo, String houseSerialNo, String newNickName, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("userSerialNo", userSerialNo);
        data.put("houseSerialNo", houseSerialNo);
        data.put("newNickName", newNickName);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/housemember/eidtmembernickname", data))
                .request(listener);
    }

    public static void getSwitchBind(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<List<SwitchBindBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> serialNoList = new ArrayList<>();
        serialNoList.add(deviceSerialNo);
        data.put("bindSerialNoList", serialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/get", data))
                .request(listener);
    }

    public static void getUserInfo(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<UserInfoBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/getuserinfo", data))
                .request(listener);
    }

    public static void addBindSwitch(LifecycleOwner lifecycleOwner, SwitchBindBean switchBindBean, HttpCallback<HttpData<SwitchBindBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/init", switchBindBean))
                .request(listener);
    }

    public static void queryBindSwitch(LifecycleOwner lifecycleOwner, String coreId, HttpCallback<HttpData<SwitchBindBean>> listener) {
        Map<String, String> map = new HashMap<>();
        map.put("coreId", coreId);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/initquery", map))
                .request(listener);
    }

    public static void addQuickBindSwitch(LifecycleOwner lifecycleOwner, Map switchMap, HttpCallback<HttpData<Map>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/activeadd", switchMap))
                .request(listener);
    }

    public static void queryQuickBindSwitch(LifecycleOwner lifecycleOwner, String coreId,String switchSerialNo, String switchKeyIndex,HttpCallback<HttpData<SwitchBindBean>> listener) {
        Map<String, String> map = new HashMap<>();
        map.put("taskId", coreId);
        map.put("switchSerialNo",switchSerialNo);
        map.put("switchKeyIndex",switchKeyIndex);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/activequery", map))
                .request(listener);
    }

    public static void enterswitchbind(LifecycleOwner lifecycleOwner, String coreId, int enterType, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("coreId", coreId);
        map.put("enterType", enterType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/enterswitchbind", map))
                .request(listener);
    }

    public static void deleteBindSwitch(LifecycleOwner lifecycleOwner, List<String> serialNoList, HttpCallback<HttpData<QueryCodeResultBean>> listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("serialNoList", serialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/delete", map))
                .request(listener);
    }

    public static void deleteBindSwitchQuery(LifecycleOwner lifecycleOwner, String queryCode, HttpCallback<HttpData<QueryCodeResultBean>> listener) {
        Map<String, String> map = new HashMap<>();
        map.put("queryCode", queryCode);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/querydelete", map))
                .request(listener);
    }

    public static void checkUpdate(LifecycleOwner lifecycleOwner, String clientCode, HttpCallback<HttpData<VersionBean>> listener) {
        Map<String, String> map = new HashMap<>();
        map.put("clientCode", clientCode);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/appsetting/checkupdate", map))
                .request(listener);
    }

    public static void getDeviceCustomKeyList(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<DeviceCustomUrlBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> deviceSerinalNo = new ArrayList<>();
        deviceSerinalNo.add(deviceSerialNo);
        data.put("deviceSerinalNo", deviceSerinalNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getdeivicecustomkeylist", data))
                .request(listener);
    }

    public static void getDeviceCustomKeyList(LifecycleOwner lifecycleOwner, List<String> deviceSerinalNo, HttpCallback<HttpData<DeviceCustomUrlBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerinalNo", deviceSerinalNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getdeivicecustomkeylist", data))
                .request(listener);
    }

    public static void saveDeviceCustomKey(LifecycleOwner lifecycleOwner, DeviceCustomKeyBean editKey, String keyName, HttpCallback<HttpData<DeviceCustomKeyBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo", editKey.getDeviceSerialNo());
        data.put("customKeySerialNo", editKey.getCustomKeySerialNo());
        data.put("keyIndex", Integer.parseInt(editKey.getKeyIndex()));
        data.put("keyName", keyName);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/savedevicecustomkey", data))
                .request(listener);
    }

    public static void getWeather(LifecycleOwner lifecycleOwner, double longitude, double latitude, HttpCallback<HttpData<WeatherInfoBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("longitude", longitude);
        data.put("latitude", latitude);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/getweather", data))
                .request(listener);
    }

    public static void getControllerSettings(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<ControllerBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getsettings", data))
                .request(listener);
    }

    public static void setControllerSettings(LifecycleOwner lifecycleOwner, String controllerSerialNo, ControllerSettingDto.Settings setting, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("settings", setting);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/setting", data))
                .request(listener);
    }

    public static void getControllerLoadDevices(LifecycleOwner lifecycleOwner, int pagNum, int num, String controllerSerialNo, HttpCallback<HttpData<List<Map<String,Object>>>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> controllerSerialNoList = new ArrayList<>();
        controllerSerialNoList.add(controllerSerialNo);
        data.put("pagNum", pagNum);
        data.put("num", num);
        data.put("controllerSerialNoList", controllerSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getall", data))
                .request(listener);
    }

    public static void getDeviceSettings(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<DeviceBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getsettings", data))
                .request(listener);
    }

    public static void protocolSwitch(LifecycleOwner lifecycleOwner, String controllerSerialNo, int brandValue, int protocolValue, HttpCallback<HttpData<ProtocolSwitchResultBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("brandValue", brandValue);
        data.put("protocolValue", protocolValue);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/protocolselect", data))
                .request(listener);
    }

    public static void queryProtocolSwitch(LifecycleOwner lifecycleOwner, String queryCode, HttpCallback<HttpData<ProtocolSwitchResultBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("queryCode", queryCode);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/queryprotocolselect", data))
                .request(listener);
    }

    public static void scanBluetoothDevice(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<QueryCodeResultListBean<Object, List<ScanWirelessControllerBean>>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/scanbluetooth", data))
                .request(listener);
    }

    public static void stopScanBluetoothDevice(LifecycleOwner lifecycleOwner, List<String> queryCodes, HttpCallback<HttpData<QueryCodeResultListBean<Object, List<ScanWirelessControllerBean>>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("queryCodes", queryCodes);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/stopscanbluetooth", data))
                .request(listener);
    }

    public static void queryScanBluetooth(LifecycleOwner lifecycleOwner, List<String> queryCodes, HttpCallback<HttpData<QueryCodeResultListBean<Object, List<ScanWirelessControllerBean>>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("queryCodes", queryCodes);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/queryscanbluetooth", data))
                .request(listener);
    }

    public static void addBluetoothDevice(LifecycleOwner lifecycleOwner, List<ScanWirelessControllerBean> addControllerList, HttpCallback<HttpData<QueryCodeResultListBean<String, String>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("addControllerList", addControllerList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/addbluetooth", data))
                .request(listener);
    }

    public static void queryAddBluetooth(LifecycleOwner lifecycleOwner, List<String> queryCodes, HttpCallback<HttpData<QueryCodeResultListBean<String, String>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("queryCodes", queryCodes);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/queryaddbluetooth", data))
                .request(listener);
    }

    public static void sendDeviceSetting(LifecycleOwner lifecycleOwner, String deviceSerialNo, Map<String, Object> stateData, HttpCallback<HttpData<QueryCodeResultBean<String, Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<Map> deviceList = new ArrayList();
        Map<String, Object> params = new HashMap<>();
        params.put("deviceSerialNo", deviceSerialNo);
        params.put("stateData", stateData);
        deviceList.add(params);
        data.put("deviceList", deviceList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/senddevicesetting", data))
                .request(listener);
    }

    public static void sendGroupDeviceSetting(LifecycleOwner lifecycleOwner, String deviceSerialNo, Map<String, Object> stateData, HttpCallback<HttpData<QueryCodeResultBean<String, Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceSerialNo);
        data.put("stateData", stateData);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/sendsetting", data))
                .request(listener);
    }

    public static void querySendDeviceSetting(LifecycleOwner lifecycleOwner, String queryCode, HttpCallback<HttpData<QueryCodeResultBean<String, Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("queryCode", queryCode);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/querysenddevicesetting", data))
                .request(listener);
    }

    public static void getControllersByMaster(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<List<ControllerBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getbymaster", data))
                .request(listener);
    }

    public static void getElecStatistics(LifecycleOwner lifecycleOwner, boolean isQueryHouse, String houseSerialNo, List<String> roomSerialNos, HttpCallback<HttpData<ElecPeriodBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("isQueryHouse", isQueryHouse);
        data.put("houseSerialNo", houseSerialNo);
        data.put("roomSerialNos", roomSerialNos);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("statistics/elec/statistics", data))
                .request(listener);

    }

    public static void getElecStatisticsDetail(LifecycleOwner lifecycleOwner, boolean isQueryHouse, String houseSerialNo, List<String> roomSerialNos, String startDate, String endDate, HttpCallback<HttpData<List<ElecBayBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("isQueryHouse", isQueryHouse);
        data.put("houseSerialNo", houseSerialNo);
        data.put("roomSerialNos", roomSerialNos);
        data.put("startDate", startDate);
        data.put("endDate", endDate);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("statistics/elec/statisticsdetail", data))
                .request(listener);

    }

    public static void setElecPrice(LifecycleOwner lifecycleOwner, ElecPriceBean data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("statistics/elec/setelecprice", data))
                .request(listener);

    }

    public static void getElecPrice(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<ElecPriceBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("statistics/elec/getelecprice", data))
                .request(listener);

    }


    public static void topDevice(LifecycleOwner lifecycleOwner, String deviceSerialNo, boolean isTop, int linkType, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> deviceSerialNoList = new ArrayList<>();
        deviceSerialNoList.add(deviceSerialNo);
        data.put("deviceSerialNoList", deviceSerialNoList);
        data.put("isTop", isTop);
        data.put("linkType", linkType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/devicesort/topdevice", data))
                .request(listener);
    }

    public static void topGroupDevice(LifecycleOwner lifecycleOwner, String deviceSerialNo, boolean isTop, int linkType, String areaSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceSerialNo);
        data.put("isTop", isTop);
        data.put("linkType", linkType);
        data.put("areaSerialNo",areaSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/topdevicegroup", data))
                .request(listener);
    }

    public static void rsa(LifecycleOwner lifecycleOwner, String plainText, HttpCallback<HttpData<RSA>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("plainText", plainText);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/test/encryption", data))
                .request(listener);
    }

    public static void rsa_pk(LifecycleOwner lifecycleOwner, String plainText, HttpCallback<HttpData<RSA>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("plainText", plainText);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/test/pkcs1encryption", data))
                .request(listener);
    }


    public static void re_rsa(LifecycleOwner lifecycleOwner, String cipherText, HttpCallback<HttpData<RE_RSA>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("cipherText", cipherText);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/test/decryption", data))
                .request(listener);
    }

    public static class RSA {
        public String plainText;
        public String publicKey;
        public String cipherText;
    }

    public static class RE_RSA {
        public String cipherText;
        public String plainText;
    }

    public static void getDeviceItem(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<List<DeviceBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        List<String> deviceSerialNoList = new ArrayList<>();
        deviceSerialNoList.add(deviceSerialNo);
        data.put("deviceSerialNoList", deviceSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getdeviceitem", data))
                .request(listener);
    }

    public static void resetPwd(LifecycleOwner lifecycleOwner, String phone, String smsId, String newPwd, String confirmNewPwd, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("phone", phone);
        data.put("smsId", smsId);
        newPwd = Md5Util.getMD5ofStr(newPwd);
        confirmNewPwd = Md5Util.getMD5ofStr(confirmNewPwd);
        data.put("newPwd", newPwd);
        data.put("confirmNewPwd", confirmNewPwd);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/resetpwd", data))
                .request(listener);
    }

    public static void getUserInfo(LifecycleOwner lifecycleOwner, LoginBean loginBean, HttpCallback<HttpData<UserInfoBean>> listener) {
        EasyHttp.post(lifecycleOwner).interceptor(new IRequestInterceptor() {
            @Override
            public void interceptArguments(HttpRequest<?> httpRequest, HttpParams params, HttpHeaders headers) {
                // 添加全局请求头
                if (loginBean != null && !TextUtils.isEmpty(loginBean.getToken())) {
                    headers.put("Authorization", "Bearer " + loginBean.getToken());
                }
                String phoneInfo = "(Android " + Build.VERSION.RELEASE + ";" + Build.BRAND + " " + Build.MODEL + ")";
                headers.put("User-Agent:", "Linlu/" + BuildConfig.VERSION_NAME + " " + phoneInfo);
            }

            @Override
            public Response interceptResponse(HttpRequest<?> httpRequest, Response response) throws Exception {
                if (response.code() == 401 || response.code() == 403) {
                    String text = response.body().string();
                    // 打印这个 Json 或者文本
                    EasyLog.printJson(httpRequest, text);
                    Gson gson = new Gson();
                    HttpData httpData = gson.fromJson(text, HttpData.class);
                    // 代表执行失
                    throw new ResultException(httpData.getMessage(), httpData);
                }
                return response;
            }
        }).api(new DataApi("user/user/getuserinfo"))
                .request(listener);
    }

    /**
     * 申请房屋过户
     *
     * @param lifecycleOwner
     * @param data           "houseSerialNo:房屋序列号 phone;对方手机号 isKeepMember:是否保留成员身份 smsId:上一步操作的短信ID congratulations:贺词"
     * @param listener
     */
    public static void applyTransfer(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<ApplyTransferBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/applytransfer", data))
                .request(listener);
    }

    //取消过户
    public static void cancelTransfer(LifecycleOwner lifecycleOwner, String transferSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("transferSerialNo", transferSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/revoketransfer", data))
                .request(listener);
    }

    //操作过户请求(同意 or 拒绝)
    public static void approvalTransfer(LifecycleOwner lifecycleOwner, String transferSerialNo, boolean accept, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("transferSerialNo", transferSerialNo);
        data.put("accept", accept);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/approvaltransfer", data))
                .request(listener);
    }

    //获取过户请求详情
    public static void getTransferDetail(LifecycleOwner lifecycleOwner, String transferSerialNo, HttpCallback<HttpData<ApplyTransferBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("transferSerialNo", transferSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/transferdetail", data))
                .request(listener);
    }

    //获取房屋最新一条过户记录详情
    public static void getLatestTransferDetail(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<ApplyTransferBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/latesttransferdetail", data))
                .request(listener);
    }

    //获取当前用户收到的未处理的过户请求列表
    public static void getUntreatedTransferList(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<List<ApplyTransferBean>>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/user/transfers"))
                .request(listener);
    }

    //获取面板配置
    public static void getPanelBindConfig(LifecycleOwner lifecycleOwner, String serialNo, HttpCallback<HttpData<PanelBindConfigs>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("serialNo", serialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/panelbind/getpanelbindconfig", data))
                .request(listener);
    }

    //取消面板绑定
    public static void cancelPanelConfig(LifecycleOwner lifecycleOwner, PanelBindConfig panelBindConfig, HttpCallback<HttpData<PanelBindConfig>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/panelbind/cancelbind", panelBindConfig))
                .request(listener);
    }

    //面板绑定
    public static void panelBind(LifecycleOwner lifecycleOwner, PanelBindConfig panelBindConfig, HttpCallback<HttpData<PanelBindConfig>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/panelbind/bind", panelBindConfig))
                .request(listener);
    }

    //面板绑定
    public static void checkPanelBindingStatus(LifecycleOwner lifecycleOwner, int type, String serialNo, HttpCallback<HttpData<PanelBindStatusBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("type", type);
        data.put("serialNo", serialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/panelbind/checkpanelbindingstatus", data))
                .request(listener);
    }

    //设备绑定的产品信息
    public static void getProductInfo(LifecycleOwner lifecycleOwner,String deviceSn,HttpCallback<HttpData<ProductBaseInfoBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("deviceSn",deviceSn);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getproductbaseinfobydevicesn",data))
                .request(listener);
    }

    //设备绑定
    public static void getDevicesBinding(LifecycleOwner lifecycleOwner,String houseSerialNo,String code,Boolean authorize,HttpCallback<HttpData<Void>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("houseSerialNo",houseSerialNo);
        data.put("code",code);
        data.put("authorize",authorize);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/open/authorize",data))
                .request(listener);
    }

    //获取指示灯设置
    public static void getDeviceLedSet(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<DeviceLedSetBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getdeviceledset",data))
                .request(listener);
    }

    //全局操作设备
    public static void getGloBaLopeRationDevice(LifecycleOwner lifecycleOwner,String houseSerialNo,Map<String,Object> deviceItem,Boolean isSyncAll,String[] deviceTypeList, HttpCallback<HttpData<GloBaLoPeRationDeviceBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("houseSerialNo",houseSerialNo);
        data.put("deviceItem",deviceItem);
        data.put("isSyncAll",isSyncAll);
        if (isSyncAll){
            try {
                data.put("deviceTypeList", new JSONArray(deviceTypeList));  //需要同步的小类列表，IsSyncAll=true时传值
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/globaloperationdevice",data))
                .request(listener);
    }

    //收藏/取消收藏歌曲
    public static void getSetFavouriteMusic(LifecycleOwner lifecycleOwner,String serialNo,String[] musicIDS,Boolean isFavourite,HttpCallback<HttpData<Void>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("serialNo",serialNo);
        try {
            data.put("musicIDS",new JSONArray(musicIDS));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        data.put("isFavourite",isFavourite);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/backgroundmusic/setfavouritemusic",data))
                .request(listener);
    }

    //获取当前播放歌曲列表
    public static void getMusicList(LifecycleOwner lifecycleOwner,String serialNo,HttpCallback<HttpData<MusicListBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("serialNo",serialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/backgroundmusic/getmusiclist",data))
                .request(listener);
    }

    //获取收藏歌曲列表
    public static void getfavouritemusicinfo(LifecycleOwner lifecycleOwner,String serialNo,HttpCallback<HttpData<MusiclikeListBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("serialNo",serialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/backgroundmusic/getfavouritemusicinfo",data))
                .request(listener);
    }

    //播放视频信息
    public static void getPlayInfo(LifecycleOwner lifecycleOwner,String deviceSerialNo,HttpCallback<HttpData<PlayInfoBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getplayinfo",data))
                .request(listener);
    }

    //门禁事件
    public static void getHiKall(LifecycleOwner lifecycleOwner, BeforePagataBean beforePagata, String dateTime, String houseSerialNo, Integer executionType, HttpCallback<HttpData<HikallBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("beforePagata",beforePagata);
        data.put("dateTime",dateTime);
        data.put("houseSerialNo",houseSerialNo);
        data.put("executionType",executionType);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/timerecord/gethikall",data))
                .request(listener);
    }

    //保存推送设置
    public static void getSave(LifecycleOwner lifecycleOwner, String deviceSerialNo, List<UserPushSetsBean.UserPushSets> userPushSets, HttpCallback<HttpData<Void>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        data.put("userPushSets",userPushSets);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/pushmessageset/save",data))
                .request(listener);
    }

    //查询推送用户终端
    public static void getUserPushSets(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<UserPushSetsBean>> listener){
        Map<String,Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/pushmessageset/get",data))
                .request(listener);
    }

    public static void house_getGroupDevice(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<DeviceBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/gethousegroup", data))
                .request(listener);
    }

    public static void operationDeviceGroup(LifecycleOwner lifecycleOwner, String deviceSerialNo, Map<String, Object> stateData, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceSerialNo);
        data.put("stateData", stateData);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/operation", data))
                .request(listener);
    }

    public static void operationAllDeviceGroup(LifecycleOwner lifecycleOwner,  List<Map<String, Object>> operations, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceList", operations);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/operation", data))
                .request(listener);
    }

    public static void modifyDeviceGroup(LifecycleOwner lifecycleOwner, DeviceBean device, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("groupSerialNo", device.getDeviceSerialNo());
        data.put("groupName", device.getName());
        data.put("ico", device.getImageUrl());
        data.put("roomSerialNo", device.getRoomSerialNo());
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/modify", data))
                .request(listener);
    }

    public static void deviceGroupBelong(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/belong", data))
                .request(listener);
    }

    public static void deviceGroupIsFavourite(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/favourites", data))
                .request(listener);
    }

    public static void deviceGroupIsHomePage(LifecycleOwner lifecycleOwner, List<String> deviceSerialNoList, boolean isHomePage, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNos", deviceSerialNoList);
        data.put("isHomePage", isHomePage);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/homepages", data))
                .request(listener);
    }

    public static void addGroupDevice(LifecycleOwner lifecycleOwner, DeviceBean deviceBean,List<Map> list, HttpCallback<HttpData<QueryCodeResultBean<String, DeviceBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("name", deviceBean.getName());
        data.put("floorSerialNo ",deviceBean.getFloorSerialNo());
        data.put("isFavourite", true);
        data.put("imageUrl", deviceBean.getImageUrl());
        data.put("houseSerialNo", deviceBean.getHouseSerialNo());
        data.put("linkType", deviceBean.getLinkType());
        data.put("roomSerialNo", deviceBean.getRoomSerialNo());
        data.put("isHomePage", true);
        data.put("deviceBindGroups", list);
//        data.put("deviceBindGroups", deviceBean.getIsFavourite());
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/add", data))
                .request(listener);
    }

    public static void saveGroupDevice(LifecycleOwner lifecycleOwner, String groupSerialNo, List<Map> deviceSerialNoList, HttpCallback<HttpData<QueryCodeResultBean<String, DeviceBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", groupSerialNo);
        data.put("deviceBindGroups", deviceSerialNoList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/savegroupdevice", data))
                .request(listener);
    }

    public static void groupDissolution(LifecycleOwner lifecycleOwner, String deviceGroupSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceGroupSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/delete", data))
                .request(listener);
    }

    public static void groupRemoveDevice(LifecycleOwner lifecycleOwner, String deviceGroupSerialNo,String deviceSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceGroupSerialNo);
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/removedevice", data))
                .request(listener);
    }

    public static void groupJoinDevice(LifecycleOwner lifecycleOwner, String deviceGroupSerialNo,String deviceSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo", deviceGroupSerialNo);
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/joindevice", data))
                .request(listener);
    }

    public static void getDeviceBySerialNo(LifecycleOwner lifecycleOwner, String deviceSerialNo, HttpCallback<HttpData<DeviceBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getsettings", data))
                .request(listener);
    }

    public static void getSourceHomepage(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<SourceHomepageBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/area/getall", data))
                .request(listener);
    }

    public static void setRoomEnvironemntIsOn(LifecycleOwner lifecycleOwner, String serialNo, Boolean isHomePage, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("serialNo", serialNo);
        data.put("isHomePage", isHomePage);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/area/savehomepage", data))
                .request(listener);
    }

    public static void setRoomEnvironemntFromDevice(LifecycleOwner lifecycleOwner, String serialNo, String deviceSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("serialNo", serialNo);
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/area/fromdevice", data))
                .request(listener);
    }

    public static void addRoomEnvironemnt(LifecycleOwner lifecycleOwner, Map<String, Object> data, HttpCallback<HttpData<SourceHomepageBean>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/area/add", data))
                .request(listener);
    }

    public static void controllerReplaceInit(LifecycleOwner lifecycleOwner, int replaceType, String replaceSerialNo, String newCodeNo, HttpCallback<HttpData<Map<String,Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("replaceType", replaceType);
        data.put("replaceSerialNo", replaceSerialNo);
        data.put("newCodeNo", newCodeNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/replacerecord/init", data))
                .request(listener);
    }

    public static void checkControllerReplace(LifecycleOwner lifecycleOwner, int replaceType, String replaceSerialNo, HttpCallback<HttpData<Map<String,Object>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("replaceType", replaceType);
        data.put("replaceSerialNo", replaceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/replacerecord/getinit", data))
                .request(listener);
    }

    public static void retryControllerReplace(LifecycleOwner lifecycleOwner, String replaceRecordSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("replaceRecordSerialNo", replaceRecordSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/replacerecord/retry", data))
                .request(listener);
    }

    public static void l8dcGetCompose(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<SchemeConfig>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getschemeconfig", data))
                .request(listener);
    }

    public static void l8dcSetCompose(LifecycleOwner lifecycleOwner, String controllerSerialNo, String productSchemeConfigSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("productSchemeConfigSerialNo", productSchemeConfigSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/selectschemeconfig", data))
                .request(listener);
    }

    public static void getCustomKeyList(LifecycleOwner lifecycleOwner, String houseSerialNo, HttpCallback<HttpData<List<DeviceCustomKeyBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/getdevicecustomkey", data))
                .request(listener);
    }

    public static void updateDeviceEables(LifecycleOwner lifecycleOwner, List<String> enables, List<String> disables, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("enableList", enables);
        data.put("disableList", disables);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/updateenables", data))
                .request(listener);
    }

    public static void copyScene(LifecycleOwner lifecycleOwner, String sceneSerialNo, HttpCallback<HttpData<CreateSceneResult>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNo", sceneSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/copy", data))
                .request(listener);
    }

    public static void controllerSort(LifecycleOwner lifecycleOwner, List<ControllerBean> controllerBeans, HttpCallback<HttpData<Void>> listener) {
        if (controllerBeans == null) return;
        Map<String, Object> data = new HashMap<>();
        List<Map<String, String>> sortSceneList = new ArrayList<>();
        for (int i = 0; i < controllerBeans.size(); i++) {
            ControllerBean bean = controllerBeans.get(i);
            bean.setSort(i);
            Map<String, String> map = new HashMap<>();
            map.put("controllerSerialNo", bean.getControllerSerialNo());
            map.put("sort", String.valueOf(i));
            sortSceneList.add(map);
        }
        data.put("sortList", sortSceneList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/savesort", data))
                .request(listener);
    }

    public static void saveCustomKeyName(LifecycleOwner lifecycleOwner, DeviceCustomKeyBean editKey, String keyName, HttpCallback<HttpData<List<DeviceCustomKeyBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo",editKey.getDeviceSerialNo());
        List<Map<String, Object>> customKey = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("keyIndex",Integer.parseInt(editKey.getKeyIndex()));
        map.put("keyName",keyName);
        customKey.add(map);
        data.put("keyNames", customKey);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/savecustomkeyname", data))
                .request(listener);
    }

    public static void searchMusic(LifecycleOwner lifecycleOwner, String deviceSerialNo, String keyword, HttpCallback<HttpData<IntTaskID>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        data.put("keyword",keyword);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/backgroundmusic/search", data))
                .request(listener);
    }

    public static void searchMusicQuery(LifecycleOwner lifecycleOwner, String deviceSerialNo, long taskId, HttpCallback<HttpData<MusicListBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        data.put("taskId",taskId);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/backgroundmusic/getsearchlist", data))
                .request(listener);
    }

    public static void getDefaultGallery(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<List<RoomGalleryBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/getdefimagelist", data))
                .request(listener);
    }

    public static void saveRoomPic(LifecycleOwner lifecycleOwner,  String roomSerialNo, String url,HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("roomSerialNo",roomSerialNo);
        data.put("url",url);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/savepic", data))
                .request(listener);
    }

    public static void floorSort(LifecycleOwner lifecycleOwner, List<FloorBean> floorBeans, HttpCallback<HttpData<Void>> listener) {
        if (floorBeans == null) return;
        Map<String, Object> data = new HashMap<>();
        List<Map<String, String>> sortFloorList = new ArrayList<>();
        for (int i = 0; i < floorBeans.size(); i++) {
            FloorBean bean = floorBeans.get(i);
            bean.setSort(i);
            Map<String, String> map = new HashMap<>();
            map.put("serialNo", bean.getFloorSerialNo());
            map.put("sort", String.valueOf(i));
            sortFloorList.add(map);
        }
        data.put("sortList", sortFloorList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/updatesort", data))
                .request(listener);
    }

    public static void getDeviceInfo(LifecycleOwner lifecycleOwner, String deviceSerialNo ,HttpCallback<HttpData<DeviceOtherBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getinfo", data))
                .request(listener);
    }

    public static void getGroupDeviceInfo(LifecycleOwner lifecycleOwner, String deviceSerialNo ,HttpCallback<HttpData<DeviceOtherBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceGroupSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/group/getinfo", data))
                .request(listener);
    }

    public static void reportPhotoAnalyse(LifecycleOwner lifecycleOwner, String houseSerialNo ,HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo",houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/reducetimes", data))
                .request(listener);
    }

    public static void roomSceneSort(LifecycleOwner lifecycleOwner, List<SceneBean> sceneBeans, HttpCallback<HttpData<Void>> listener) {
            if (sceneBeans == null) return;
            Map<String, Object> data = new HashMap<>();
            List<Map<String, String>> sortSceneList = new ArrayList<>();
            for (int i = 0; i < sceneBeans.size(); i++) {
                SceneBean bean = sceneBeans.get(i);
                bean.setRoomSort(i);
                Map<String, String> map = new HashMap<>();
                map.put("serialNo", bean.getSceneSerialNo());
                map.put("roomSort", String.valueOf(i));
                sortSceneList.add(map);
            }
            data.put("sortList", sortSceneList);
            EasyHttp.post(lifecycleOwner)
                    .api(new DataApi("device/scene/updateroomsort", data))
                    .request(listener);
    }

    public static void floorSceneSort(LifecycleOwner lifecycleOwner, List<SceneBean> sceneBeans, HttpCallback<HttpData<Void>> listener) {
        if (sceneBeans == null) return;
        Map<String, Object> data = new HashMap<>();
        List<Map<String, String>> sortSceneList = new ArrayList<>();
        for (int i = 0; i < sceneBeans.size(); i++) {
            SceneBean bean = sceneBeans.get(i);
            bean.setFloorSort(i);
            Map<String, String> map = new HashMap<>();
            map.put("serialNo", bean.getSceneSerialNo());
            map.put("sort", String.valueOf(i));
            sortSceneList.add(map);
        }
        data.put("sortList", sortSceneList);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/updatefloorsort", data))
                .request(listener);
    }

    public static void getAllDeviceTgpactions(LifecycleOwner lifecycleOwner, String houseSerialNo ,HttpCallback<HttpData<UniversalDeviceAction>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo",houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/gettgpactionlist", data))
                .request(listener);
    }

    public static void getDeviceTgpactions(LifecycleOwner lifecycleOwner, String deviceSerialNo ,HttpCallback<HttpData<UniversalDeviceAction>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNo",deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/getdevicetgpactions", data))
                .request(listener);
    }

    public static void saveDeviceTgpactions(LifecycleOwner lifecycleOwner, List<UniversalDeviceData> dtos, String houseSerialNo , HttpCallback<HttpData<UniversalDeviceAction>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("tgpActions",dtos);
        data.put("houseSerialNo",houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/deviceitem/savetgpaction", data))
                .request(listener);
    }

    public static void getInterrupData(LifecycleOwner lifecycleOwner, String sceneSerialNo, HttpCallback<HttpData<SceneInterruptModeBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNo", sceneSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/getactionsettinglist", data))
                .request(listener);
    }

    public static void setInterrupData(LifecycleOwner lifecycleOwner, SceneInterruptModeBean bean, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/saveactionsetting", bean))
                .request(listener);
    }

    public static void cancelInterrupMode(LifecycleOwner lifecycleOwner, String sceneSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("sceneSerialNo", sceneSerialNo);
        data.put("isEnable", true);
        data.put("isRelease", true);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/scene/saveactionsettingenable", data))
                .request(listener);
    }

    public static void panelBatchBind(LifecycleOwner lifecycleOwner, List<PanelBindConfig> config, HttpCallback<HttpData<Void>> listener) {
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/panelbind/batchbind", config))
                .request(listener);
    }

    public static void getRoomShareList(LifecycleOwner lifecycleOwner, String houseSerialNo, String roomSerialNo, HttpCallback<HttpData<Map<String,List<RoomShareBean>>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("roomSerialNo", roomSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/getsharelist", data))
                .request(listener);
    }

    public static void deleteRoomShare(LifecycleOwner lifecycleOwner, String houseSerialNo, String roomSerialNo, String shareSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("roomSerialNo", roomSerialNo);
        data.put("shareSerialNo", shareSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/deleteshare", data))
                .request(listener);
    }

    public static void shareRoom(LifecycleOwner lifecycleOwner, String houseSerialNo, String roomSerialNo, RoomShareBean shareBean, HttpCallback<HttpData<Map<String ,String>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("roomSerialNo", roomSerialNo);
        if(shareBean.getShareSerialNo() != null){
            data.put("shareSerialNo", shareBean.getShareSerialNo());
        }
        data.put("name", shareBean.getName());
        data.put("fromTime", shareBean.getFromTime());
        data.put("toTime", shareBean.getToTime());
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/share", data))
                .request(listener);
    }

    public static void getRoomInfo(LifecycleOwner lifecycleOwner, String roomSerialNo, HttpCallback<HttpData<RoomBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("roomSerialNo", roomSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/room/getinfo", data))
                .request(listener);
    }

    public static void getKGPanelList(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<List<KGSwitchBindBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/switchbind/getlistbycontroller", data))
                .request(listener);
    }

    public static void getFloorDefaultGallery(LifecycleOwner lifecycleOwner, HttpCallback<HttpData<List<RoomGalleryBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/getdefimagelist", data))
                .request(listener);
    }

    public static void saveFloorPic(LifecycleOwner lifecycleOwner, String floorSerialNo, String url,HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("floorSerialNo",floorSerialNo);
        data.put("url",url);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/floor/savepic", data))
                .request(listener);
    }

    public static void saveHousePic(LifecycleOwner lifecycleOwner, String houseSerialNo, String newAvatar,HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo",houseSerialNo);
        data.put("newAvatar",newAvatar);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/editavatar", data))
                .request(listener);
    }

    /* 获取过户
     * 返回值：ApplyTransferBean
     * 返回值说明：
     */
    public static void getApplyTransfer(LifecycleOwner lifecycleOwner,  HttpCallback<HttpData<ApplyTransferBean>> listener) {
        Map<String, Object> data = new HashMap<>();
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("user/house/getapplytransfer", data))
                .request(listener);
    }

    public static void topHouseDevice(LifecycleOwner lifecycleOwner, String houseSerialNo, int sort, int itemType, String targetSerialNo, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("itemType", itemType);
        data.put("targetSerialNo", targetSerialNo);
        data.put("sort", sort);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/updatefloorglobalsort", data))
                .request(listener);
    }

    public static void favouritedevice(LifecycleOwner lifecycleOwner, List<String> deviceList, List<String> groupList, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("deviceSerialNoList", deviceList);
        data.put("deviceGroupSerialNoList", groupList);
        data.put("isFavourite", true);
        data.put("linkType", 2);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/devicesort/favouritedevice", data))
                .request(listener);
    }

    public static void operationController(LifecycleOwner lifecycleOwner, String controllerSerialNo, String houseSerialNo, int controllerOpr, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("controllerOpr", controllerOpr);
        data.put("houseSerialNo", houseSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/hostcoresetting", data))
                .request(listener);
    }
    //根据协议获取从机添加设备集合 kgx
    public static void getdevicecollectlistbybrand(LifecycleOwner lifecycleOwner, String controllerSerialNo, int protocolValue, int brandValue, HttpCallback<HttpData<List<KGXAddData>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("brandValue", brandValue);
        data.put("protocolValue", protocolValue);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getdevicecollectlistbybrand", data))
                .request(listener);
    }

    //根据从机序列号获取设备集合列表 获取kgx壳子使用
    public static void getdevicecollectlist(LifecycleOwner lifecycleOwner, String controllerSerialNo, HttpCallback<HttpData<List<KGXcollectionData>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/getdevicecollectlist", data))
                .request(listener);
    }

    //保存设备集合并生成负载
    public static void savedevicecollect(LifecycleOwner lifecycleOwner, List<KGXAddData> deviceCollectList,String controllerSerialNo, int protocolValue, int brandValue, HttpCallback<HttpData<Void>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("controllerSerialNo", controllerSerialNo);
        data.put("deviceCollectList", deviceCollectList);
        data.put("brandValue", brandValue);
        data.put("protocolValue", protocolValue);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/controller/savedevicecollect", data))
                .request(listener);
    }

    public static void getCustomKeyListBySerialNo(LifecycleOwner lifecycleOwner, String houseSerialNo,String deviceSerialNo,HttpCallback<HttpData<List<DeviceCustomNewBean>>> listener) {
        Map<String, Object> data = new HashMap<>();
        data.put("houseSerialNo", houseSerialNo);
        data.put("deviceSerialNo", deviceSerialNo);
        EasyHttp.post(lifecycleOwner)
                .api(new DataApi("device/house/getdevicecustomkey", data))
                .request(listener);
    }

}
